<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
    <head>
        <meta charset="UTF-8">
        <link th:href="@{/erp/assets/css/bootstrap.min.css}" rel="stylesheet"/>
        <link rel="stylesheet" th:href="@{/erp/css/style.css}"/>
        <link rel="stylesheet" th:href="@{/erp/assets/css/ace.min.css}"/>
        <link rel="stylesheet" th:href="@{/erp/assets/css/font-awesome.min.css}"/>
        <link rel="stylesheet" href="/erp/Widget/zTree/css/zTreeStyle/zTreeStyle.css" type="text/css">
        <script th:src="@{/erp/assets/js/jquery.min.js}"></script>
        <script th:src="@{/erp/assets/js/bootstrap.min.js}"></script>
        <script th:src="@{/erp/assets/js/jquery.dataTables.min.js}"></script>
        <script th:src="@{/erp/assets/js/jquery.dataTables.bootstrap.js}"></script>
        <script th:src="@{/erp/assets/layer/layer.js}" type="text/javascript"></script>
        <script type="text/javascript" th:src="@{/erp/Widget/zTree/js/jquery.ztree.all-3.5.min.js}"></script>
        <script th:src="@{/erp/js/lrtk.js}" type="text/javascript"></script>
        <title>Title</title>
    </head>
    <body>
        <script>
            $(function () {
                $.ajax({
                    url: '/procurement/productType?id=' + $("#proId").val(),
                    type: "get",
                    dataType: "json",
                    success: function (data) {
                        if (data.type == "积分商品"){
                            $("#type").text("积分")
                            $("#type1").text("积分")
                            $("#type2").text($("#integral").val())
                        }
                    }
                });
            })
        </script>
        <div class="add_menber" id="add_menber_style">
            <input id="proId" type="hidden" th:value="${product.proId}">
            <input id="integral" type="hidden" th:value="${product.integral}"/>
            <table class="table table-striped table-bordered table-hover" id="sample-table">
                <thead>
                <tr>
                    <th width="100px">订单编号</th>
                    <th id="type" width="100px">价格</th>
                    <th width="100px">产品名称</th>
                    <th width="100px">产品型号</th>
                    <th width="100px">产品数量</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td id="no" th:text="${product.orderId}"></td>
                    <td id="type2" th:text="${product.retailPrice}"></td>
                    <td th:text="${product.productName}"></td>
                    <td th:text="${product.productModel}"></td>
                    <td th:text="${product.sum}"></td>
                </tr>
                <label class="label_name">总计：[[${product.money}]]<label id="type1">元</label></label>
            </table>
            <div class="Button_operation" align="center">
                <button id="btn" class="btn btn-primary radius" type="button">确定</button>
                <button id="rtn" class="btn btn-primary radius" type="button">返回</button>
            </div>
        </div>
        </div>
    </body>
</html>
<script>
    $("#btn").on("click", function () {
        $.ajax({
            url: '/procurement/buy',
            data: {no: $("#no").text()},
            contentType: 'application/json',           //表示我们发送给服务器数据是json格式
            dataType: 'json',                          //表示服务器返回给我们的数据是json格式
            success: function (data) {
                if (data.result == true) {
                    // 提交成功后的回调
                    layer.msg('购买成功，请到采购列表查看！', {icon: 1, time: 1000}, function () {
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    });
                } else {
                    layer.msg('购买失败！', {icon: 2,});
                }
            },
            error: function (data) {
                layer.alert("购买失败：" + data.data);
            }
        })
        return false;
    })

    $("#rtn").on("click", function () {
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    })

</script>

